package com.chrray.position.domain.dto;

import com.chrray.position.enums.YesNoEnum;
import com.chrray.position.enums.app.FdGenderEnum;
import com.chrray.position.enums.app.FdSalaryCalcMethodEnum;
import com.chrray.position.enums.app.FdSalaryUnitEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.util.StringUtils;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;

/**
 * 工作岗位表 参数层对象
 *
 * @author wusiwee
 * @email wusiwee@163.com
 * @since 1.0.1 2024-08-07
 */
@Data
@ApiModel(description = "工作岗位表")
public class FdJobPostingsDTO {

    private  Long jobId;

	@ApiModelProperty(value = "是否是新农人")
	@NotNull(message = "是否是新农人不能为空")
	private Boolean newFarmer;

	@ApiModelProperty(value = "乡镇（新农人）")
	private String township;

	@ApiModelProperty(value = "工种名称")
	@NotNull(message = "工种名称不能为空")
	@Size(max = 50, message = "工种名称最大长度为50")
	private String jobName;

	@ApiModelProperty(value = "工种类目：关联职位菜单")
	//@NotNull(message = "工种类目不能为空")
	private Long jobCategory;

	@ApiModelProperty(value = "计算方式：1-计时,2-计件")
	@NotNull(message = "计算方式不能为空")
	private Integer calcMethod;

	@ApiModelProperty(value = "报酬单价：元")
	@NotNull(message = "报酬单价不能为空")
	private BigDecimal salaryPrice;

	@ApiModelProperty(value = "报酬单位：计价时: 1-小时,2-天,3-月||计件时: 11-次 12-个 13-平方 14-米 15-套 16-车 17-根")
	@NotNull(message = "报酬单位不能为空")
	private Integer salaryUnit;


	@ApiModelProperty(value = "长期-工作日期,手动输入")
	@Size(max = 50, message = "作日期最大长度为50")
	private String longTermWokeDate;

	@ApiModelProperty(value = "短期-工作日期开始：yyyy-MM-dd")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
	private Date workDateStart;

	@ApiModelProperty(value = "短期-工作日期结束：yyyy-MM-dd")
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@JsonFormat(shape=JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
	private Date workDateEnd;

	@ApiModelProperty(value = "工作时段开始：时分")
	@NotNull(message = "工作时段开始不能为空")
	private String workTimeStart;

	@ApiModelProperty(value = "工作时段结束：时分")
	@NotNull(message = "工作时段结束不能为空")
	private String workTimeEnd;

	@ApiModelProperty(value = "工作地址")
	@NotNull(message = "工作地址不能为空")
	@Size(max = 100, message = "工作地址最大长度为100")
	private String workAddress;

	@ApiModelProperty(value = "工作地址详细")
	@NotNull(message = "工作地址详细不能为空")
	@Size(max = 100, message = "工作地址详细最大长度为100")
	private String workAddressDetail;

	@ApiModelProperty(value = "工作地址,经度")
	@NotNull(message = "工作地址经度不能为空")
	private Double lat;

	@ApiModelProperty(value = "工作地址,纬度")
	@NotNull(message = "工作地址纬度不能为空")
	private Double lon;

	@ApiModelProperty(value = "工作地址行政区")
	@NotNull(message = "工作地址行政区不能为空")
	private String districtId;

	@ApiModelProperty(value = "工作内容")
	@NotNull(message = "工作内容不能为空")
	@Size(max = 500, message = "工作内容最大长度为500")
	private String workContent;

	@ApiModelProperty(value = "相关照片")
	private List<String> relatedImges;

	@ApiModelProperty(value = "人数")
	@NotNull(message = "人数不能为空")
	@Min(value = 1, message = "人数最小为1")
	private Integer numberOfWorkers;

	@ApiModelProperty(value = "性别:1-男,2-女,3-不限")

	private Integer gender;

	@ApiModelProperty(value = "年龄开始,岁")
	private Integer ageStart;

	@ApiModelProperty(value = "年龄结束,岁")
	private Integer ageEnd;

	@ApiModelProperty(value = "身高开始,厘米")
	private Integer heightStart;

	@ApiModelProperty(value = "身高结束,厘米")
	private Integer heightEnd;

	@ApiModelProperty(value = "是否需要专业经验,0-不需要,1-需要")
	private Integer requiresExperience;

	@ApiModelProperty(value = "联系人姓名")
	@NotNull(message = "联系人姓名不能为空")
	@Size(max = 20, message = "联系人姓名最大长度为20")
	private String contactName;

	@ApiModelProperty(value = "联系人手机号")
	@NotNull(message = "联系人手机号不能为空")
	@Pattern(regexp = "^1[0-9]{10}$", message = "联系人手机号格式不正确")
	private String contactPhone;

    @ApiModelProperty(value = "区域id")
    private Long areaId;


	public boolean workDateValid() {
		if(StringUtils.hasLength(longTermWokeDate)) {
			this.workDateStart = null;
			this.workDateEnd = null;
			return true;
		}
        return workDateStart != null && workDateEnd != null;
    }
}
